#ifndef GAME_H_
#define GAME_H_

#include "Singleton.h"
#include "NonCopyable.h"
#include "EventHandler.h"
#include "AntTweakBar.h"
#include <assert.h>

class GameState;
/* The main Game singleton */

/* To Do: - 
        * Update state management to stop use of singletons 
*/
class Game : public EventHandler, NonCopyable
{
private:
	Game();
	friend class Singleton<Game>;

public:
    /* The return function for int main()*/
	int				Execute();
    /* Sets up the screen, first gamestate and SDL/OpenGl related specifics */
	bool			Initialise();
    /* Main Update function */
	void			Update();
    /* The main rendering function */
	void			Draw();
    /* Tidys up memory and singletons */
	void			CleanUp();
    /* Quits the current game */
    void            Quit();
    /* State Management Functions */
	void			ChangeState(GameState*);
	void			RequestChange(GameState*);
	void			ManageStates();

    /* Attempt at allowing users to plug joysticks in
     * on the fly */
    void            ScanForInput();

private:
    /* The boolean used to keep game running */
	bool			m_running;
    /* Gamestate pointers */
	GameState*		m_requestState;
	GameState*		m_currentState;

};

#define TestTw(x){{int local = (x); if(local != 1){ const char* out = TwGetLastError(); std::cout << out; assert(0);}}}

typedef Singleton<Game> TheGame;

#endif